#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <sys/time.h>
#include <unistd.h>
#include <stdarg.h>

#include "tlib_all.h"

int main(int argc, char *argv[])
{
		
	unsigned int  iCount;
	int i,iSessionID,iRetCode;
	char sSessionKey[200];
	char sErrMsg[200];
   	struct timeval tv;

	if (argc < 2)
	{
		printf("Usage: %s count \nSample: %s 192.168.1.9 6666 100\n", argv[0], argv[0]);
		return -1;
   	}
   	
   	
   	iCount=atoi(argv[1]);
   	gettimeofday(&tv,NULL);
	printf("cur time is %ld.%ld seconds \n",tv.tv_sec,tv.tv_usec);
	for (i=0;i<iCount;i++){
		iRetCode=ApplySession(&iSessionID,sSessionKey,sErrMsg);
		if (iRetCode==0)
		{
			//printf("iSessionID=%d\n",iSessionID);
			//printf("sSessionKey=%d\n",sSessionKey);
		}
		else
		{
			printf("failed\n");
		}
	}
	gettimeofday(&tv,NULL);
   	printf("cur time is %ld.%ld seconds \n",tv.tv_sec,tv.tv_usec);
	
}
